home *** CD-ROM | disk | FTP | other *** search
/ Visual Cafe 3 / Visual Cafe 3.ISO / Vcafe / JFC.bin / JFrame.java < prev    next >
Text File  |  1998-06-30  |  30KB  |  933 lines

  1. /*
  2.  * @(#)JFrame.java    1.48 98/04/03
  3.  * 
  4.  * Copyright (c) 1997 Sun Microsystems, Inc. All Rights Reserved.
  5.  * 
  6.  * This software is the confidential and proprietary information of Sun
  7.  * Microsystems, Inc. ("Confidential Information").  You shall not
  8.  * disclose such Confidential Information and shall use it only in
  9.  * accordance with the terms of the license agreement you entered into
  10.  * with Sun.
  11.  * 
  12.  * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE
  13.  * SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  14.  * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
  15.  * PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR ANY DAMAGES
  16.  * SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING
  17.  * THIS SOFTWARE OR ITS DERIVATIVES.
  18.  * 
  19.  */
  20. package com.sun.java.swing;
  21.  
  22. import java.awt.*;
  23. import java.awt.event.*;
  24. import java.beans.PropertyChangeListener;
  25. import java.util.Locale;
  26. import java.util.Vector;
  27. import java.io.Serializable;
  28.  
  29. import com.sun.java.accessibility.*;
  30.  
  31.  
  32. /**
  33.  * An extended version of java.awt.Frame that adds support for 
  34.  * interposing input and painting behavior in front of the frames
  35.  * children (see glassPane), support for special children that 
  36.  * are managed by a LayeredPane (see rootPane) and for Swing MenuBars.
  37.  * <p>
  38.  * The JFrame class is slightly incompatible with java.awt.Frame.
  39.  * JFrame contains a JRootPane as it's only child.
  40.  * The <b>contentPane</b> should be the parent of any children of the JFrame.
  41.  * This is different than java.awt.Frame, e.g. to add a child to 
  42.  * an AWT Frame you'd write:
  43.  * <pre>
  44.  *       frame.add(child);
  45.  * </pre>
  46.  * However using JFrame you need to add the child to the JFrames contentPane
  47.  * instead:
  48.  * <pre>
  49.  *       frame.getContentPane().add(child);
  50.  * </pre>
  51.  * The same is true for setting LayoutManagers, removing components,
  52.  * listing children, etc. All these methods should normally be sent to
  53.  * the contentPane() instead of the JFrame itself. The contentPane() will
  54.  * always be non-null. Attempting to set it to null will cause the JFrame
  55.  * to throw an exception. The default contentPane() will have a BorderLayout
  56.  * manager set on it. 
  57.  * <p>
  58.  * Please see the JRootPane documentation for a complete description of
  59.  * the contentPane, glassPane, and layeredPane properties.
  60.  * <p>
  61.  * For the keyboard keys used by this component in the standard Look and
  62.  * Feel (L&F) renditions, see the
  63.  * <a href="doc-files/Key-Index.html#JFrame">JFrame</a> key assignments.
  64.  * <p>
  65.  * Warning: serialized objects of this class will not be compatible with
  66.  * future swing releases.  The current serialization support is appropriate 
  67.  * for short term storage or RMI between Swing1.0 applications.  It will
  68.  * not be possible to load serialized Swing1.0 objects with future releases
  69.  * of Swing.  The JDK1.2 release of Swing will be the compatibility
  70.  * baseline for the serialized form of Swing objects.
  71.  *
  72.  * @see JRootPane
  73.  *
  74.  * @beaninfo
  75.  *      attribute: isContainer true
  76.  *      attribute: containerDelegate getContentPane
  77.  *    description: A toplevel window which can be minimized to an icon.
  78.  *
  79.  * @version 1.48 04/03/98
  80.  * @author Jeff Dinkins
  81.  * @author Georges Saab
  82.  * @author David Kloba
  83.  */
  84. public class JFrame  extends Frame implements WindowConstants, Accessible, RootPaneContainer
  85. {
  86.     private int defaultCloseOperation = HIDE_ON_CLOSE;
  87.  
  88.     /**
  89.      * The JRootPane instance that manages the <code>contentPane</code> 
  90.      * and optional <code>menuBar</code> for this frame, as well as the 
  91.      * <code>glassPane</code>.
  92.      *
  93.      * @see JRootPane
  94.      * @see RootPaneContainer
  95.      */
  96.     protected JRootPane rootPane;
  97.  
  98.     /**
  99.      * If true then calls to <code>add</code> and <code>setLayout</code>
  100.      * cause an exception to be thrown.
  101.      *
  102.      * @see #isRootPaneCheckingEnabled
  103.      * @see #setRootPaneCheckingEnabled
  104.      */
  105.     protected boolean rootPaneCheckingEnabled = false;
  106.  
  107.  
  108.     /**
  109.      * Constructs a new Frame that is initially invisible.
  110.      *
  111.      * @see Component#setSize
  112.      * @see Component#setVisible
  113.      */
  114.     public JFrame() {
  115.         super();        
  116.         frameInit();
  117.     }
  118.  
  119.     /**
  120.      * Constructs a new, initially invisible Frame with the specified
  121.      * title.
  122.      *
  123.      * @param title the title for the frame
  124.      * @see Component#setSize
  125.      * @see Component#setVisible
  126.      */
  127.     public JFrame(String title) {
  128.         super(title);
  129.         frameInit();
  130.     }
  131.  
  132.     /** Called by the constructors to init the JFrame properly. */
  133.     protected void frameInit() {
  134.         enableEvents(AWTEvent.KEY_EVENT_MASK | AWTEvent.WINDOW_EVENT_MASK);
  135.         setRootPane(createRootPane());
  136.         setBackground(UIManager.getColor("control"));
  137.         setRootPaneCheckingEnabled(true);
  138.     }
  139.  
  140.     /** Called by the constructor methods to create the default rootPane. */
  141.     protected JRootPane createRootPane() {
  142.         return new JRootPane();
  143.     }
  144.  
  145.     /** 
  146.      * Processes key events occurring on this component and, if appropriate,
  147.      * passes them on to components in the frame which have registered 
  148.      * interest in them.
  149.      *
  150.      * @param  e  the key event
  151.      * @see    java.awt.Component#processKeyEvent
  152.      */   
  153.     protected void processKeyEvent(KeyEvent e) {
  154.         super.processKeyEvent(e);
  155.         if(!e.isConsumed()) {
  156.             JComponent.processKeyBindingsForAllComponents(e,this,new Vector(),e.getID() == KeyEvent.KEY_PRESSED);
  157.         }
  158.     }
  159.  
  160.     /** 
  161.      * Processes window events occurring on this component.
  162.      * Hides the window or disposes of it, as specified by the setting
  163.      * of the <code>defaultCloseOperation</code> property.
  164.      *
  165.      * @param  e  the window event
  166.      * @see    #setDefaultCloseOperation
  167.      * @see    java.awt.Window#processWindowEvent
  168.      */
  169.     protected void processWindowEvent(WindowEvent e) {
  170.         super.processWindowEvent(e);
  171.  
  172.         if (e.getID() == WindowEvent.WINDOW_CLOSING) {
  173.             switch(defaultCloseOperation) {
  174.               case HIDE_ON_CLOSE:
  175.                  setVisible(false);
  176.                  break;
  177.               case DISPOSE_ON_CLOSE:
  178.                  setVisible(false);
  179.                  dispose();
  180.                  break;
  181.               case DO_NOTHING_ON_CLOSE:
  182.                  default: 
  183.                  break;
  184.             }
  185.         }
  186.     }
  187.  
  188. //    public void setMenuBar(MenuBar menu) {  
  189. //        throw new IllegalComponentStateException("Please use setJMenuBar() with JFrame.");
  190. //    }
  191.  
  192.     /**
  193.      * Sets the operation which will happen by default when
  194.      * the user initiates a "close" on this frame.
  195.      * The possible choices are:
  196.      * <p>
  197.      * <ul>
  198.      * <li>DO_NOTHING_ON_CLOSE - do not do anything - require the
  199.      * program to handle the operation in the windowClosing
  200.      * method of a registered WindowListener object.
  201.      * <li>HIDE_ON_CLOSE - automatically hide the frame after
  202.      * invoking any registered WindowListener objects
  203.      * <li>DISPOSE_ON_CLOSE - automatically hide and dispose the 
  204.      * frame after invoking any registered WindowListener objects
  205.      * </ul>
  206.      * <p>
  207.      * The value is set to HIDE_ON_CLOSE by default.
  208.      * @see #addWindowListener
  209.      * @see #getDefaultCloseOperation
  210.      *
  211.      * @beaninfo
  212.      *   preferred: true
  213.      *        enum: DO_NOTHING_ON_CLOSE WindowConstants.DO_NOTHING_ON_CLOSE
  214.      *              HIDE_ON_CLOSE       WindowConstants.HIDE_ON_CLOSE
  215.      *              DISPOSE_ON_CLOSE    WindowConstants.DISPOSE_ON_CLOSE
  216.      * description: The frame's default close operation.
  217.      */
  218.     public void setDefaultCloseOperation(int operation) {
  219.         this.defaultCloseOperation = operation;
  220.     }
  221.  
  222.  
  223.    /**
  224.     * Returns the operation which occurs when the user
  225.     * initiates a "close" on this frame.
  226.     *
  227.     * @return an int indicating the window-close operation
  228.     * @see #setDefaultCloseOperation
  229.     */
  230.     public int getDefaultCloseOperation() {
  231.         return defaultCloseOperation;
  232.     }
  233.  
  234.  
  235.     /** 
  236.      * Just calls <code>paint(g)</code>.  This method was overridden to 
  237.      * prevent an unneccessary call to clear the background.
  238.      *
  239.      * @param g the Graphics context in which to paint
  240.      */
  241.     public void update(Graphics g) {
  242.         paint(g);
  243.     }
  244.  
  245.    /**
  246.     * Sets the menubar for this frame.
  247.     * @param menubar the menubar being placed in the frame
  248.     *
  249.     * @see #getJMenuBar
  250.     *
  251.     * @beaninfo
  252.     *      hidden: true
  253.     * description: The menubar for accessing pulldown menus from this frame.
  254.     */
  255.     public void setJMenuBar(JMenuBar menubar) {
  256.         getRootPane().setMenuBar(menubar);
  257.     }
  258.  
  259.    /**
  260.     * Returns the menubar set on this frame.
  261.     *
  262.     * @see #setJMenuBar
  263.     */
  264.     public JMenuBar getJMenuBar() { 
  265.         return getRootPane().getMenuBar(); 
  266.     }
  267.  
  268.     /**
  269.      * Returns whether calls to <code>add</code> and 
  270.      * <code>setLayout</code> cause an exception to be thrown. 
  271.      *
  272.      * @return true if <code>add</code> and <code>setLayout</code> 
  273.      *         are checked
  274.      *
  275.      * @see #addImpl
  276.      * @see #setLayout
  277.      * @see #setRootPaneCheckingEnabled
  278.      */
  279.     protected boolean isRootPaneCheckingEnabled() {
  280.         return rootPaneCheckingEnabled;
  281.     }
  282.  
  283.  
  284.     /**
  285.      * Determines whether calls to <code>add</code> and 
  286.      * <code>setLayout</code> cause an exception to be thrown. 
  287.      * 
  288.      * @param enabled  a boolean value, true if checking is to be
  289.      *        enabled, which cause the exceptions to be thrown
  290.      *
  291.      * @see #addImpl
  292.      * @see #setLayout
  293.      * @see #isRootPaneCheckingEnabled
  294.      * @beaninfo
  295.      *      hidden: true
  296.      * description: Whether the add and setLayout methods throw exceptions when invoked.
  297.      */
  298.     protected void setRootPaneCheckingEnabled(boolean enabled) {
  299.         rootPaneCheckingEnabled = enabled;
  300.     }
  301.  
  302.  
  303.     /**
  304.      * Creates a runtime exception with a message like:
  305.      * <pre>
  306.      * "Do not use JFrame.add() use JFrame.getContentPane().add() instead"
  307.      * </pre>
  308.      *
  309.      * @param op  a String indicating the attempted operation. In the
  310.      *            example above, the operation string is "add"
  311.      */
  312.     private Error createRootPaneException(String op) {
  313.         String type = getClass().getName();
  314.         return new Error(
  315.             "Do not use " + type + "." + op + "() use " 
  316.                           + type + ".getContentPane()." + op + "() instead");
  317.     }
  318.  
  319.  
  320.     /**
  321.      * By default, children may not be added directly to a this component,
  322.      * they must be added to its contentPane instead.  For example:
  323.      * <pre>
  324.      * thisComponent.getContentPane().add(child)
  325.      * </pre>
  326.      * An attempt to add to directly to this component will cause an
  327.      * runtime exception to be thrown.  Subclasses can disable this
  328.      * behavior.
  329.      * 
  330.      * @see #setRootPaneCheckingEnabled
  331.      * @exception Error if called with rootPaneChecking true
  332.      */
  333.     protected void addImpl(Component comp, Object constraints, int index) 
  334.     {
  335.         if(isRootPaneCheckingEnabled()) {
  336.             throw createRootPaneException("add");
  337.         }
  338.         else {
  339.             super.addImpl(comp, constraints, index);
  340.         }
  341.     }
  342.  
  343.  
  344.     /**
  345.      * By default the layout of this component may not be set,
  346.      * the layout of its contentPane should be set instead.  
  347.      * For example:
  348.      * <pre>
  349.      * thiComponent.getContentPane().setLayout(new BorderLayout())
  350.      * </pre>
  351.      * An attempt to set the layout of this component will cause an
  352.      * runtime exception to be thrown.  Subclasses can disable this
  353.      * behavior.
  354.      * 
  355.      * @see #setRootPaneCheckingEnabled
  356.      * @exception Error if called with rootPaneChecking true
  357.      */
  358.     public void setLayout(LayoutManager manager) {
  359.         if(isRootPaneCheckingEnabled()) {
  360.             throw createRootPaneException("setLayout");
  361.         }
  362.         else {
  363.             super.setLayout(manager);
  364.         }
  365.     }
  366.  
  367.  
  368.     /**
  369.      * Returns the rootPane object for this frame.
  370.      *
  371.      * @see #setRootPane
  372.      * @see RootPaneContainer#getRootPane
  373.      */
  374.     public JRootPane getRootPane() { 
  375.         return rootPane; 
  376.     }
  377.  
  378.  
  379.     /**
  380.      * Sets the rootPane property.  This method is called by the constructor.
  381.      * @param root the rootPane object for this frame
  382.      *
  383.      * @see #getRootPane
  384.      *
  385.      * @beaninfo
  386.      *   hidden: true
  387.      * description: the RootPane object for this frame.
  388.      */
  389.     protected void setRootPane(JRootPane root) 
  390.     {
  391.         if(rootPane != null) {
  392.             remove(rootPane);
  393.         }
  394.         rootPane = root;
  395.         if(rootPane != null) {
  396.             boolean checkingEnabled = isRootPaneCheckingEnabled();
  397.             try {
  398.                 setRootPaneCheckingEnabled(false);
  399.                 add(rootPane, BorderLayout.CENTER);
  400.             }
  401.             finally {
  402.                 setRootPaneCheckingEnabled(checkingEnabled);
  403.             }
  404.         }
  405.     }
  406.  
  407.  
  408.     /**
  409.      * Returns the contentPane object for this frame.
  410.      *
  411.      * @see #setContentPane
  412.      * @see RootPaneContainer#getContentPane
  413.      */
  414.     public Container getContentPane() { 
  415.         return getRootPane().getContentPane(); 
  416.     }
  417.  
  418.     /**
  419.      * Sets the contentPane property.  This method is called by the constructor.
  420.      * @param contentPane the contentPane object for this frame
  421.      *
  422.      * @exception java.awt.IllegalComponentStateException (a runtime
  423.      *            exception) if the content pane parameter is null
  424.      * @see #getContentPane
  425.      * @see RootPaneContainer#setContentPane
  426.      *
  427.      * @beaninfo
  428.      *     hidden: true
  429.      *     description: The client area of the frame where child 
  430.      *                  components are normally inserted.
  431.      */
  432.     public void setContentPane(Container contentPane) {
  433.         getRootPane().setContentPane(contentPane);
  434.     }
  435.  
  436.     /**
  437.      * Returns the layeredPane object for this frame.
  438.      *
  439.      * @see #setLayeredPane
  440.      * @see RootPaneContainer#getLayeredPane
  441.      */
  442.     public JLayeredPane getLayeredPane() { 
  443.         return getRootPane().getLayeredPane(); 
  444.     }
  445.  
  446.     /**
  447.      * Sets the layeredPane property.  This method is called by the constructor.
  448.      * @param layeredPane the layeredPane object for this frame
  449.      *
  450.      * @exception java.awt.IllegalComponentStateException (a runtime
  451.      *            exception) if the layered pane parameter is null
  452.      * @see #getLayeredPane
  453.      * @see RootPaneContainer#setLayeredPane
  454.      *
  455.      * @beaninfo
  456.      *     hidden: true
  457.      *     description: The pane which holds the various frame layers.
  458.      */
  459.     public void setLayeredPane(JLayeredPane layeredPane) {
  460.         getRootPane().setLayeredPane(layeredPane);
  461.     }
  462.  
  463.     /**
  464.      * Returns the glassPane object for this frame.
  465.      *
  466.      * @see #setGlassPane
  467.      * @see RootPaneContainer#getGlassPane
  468.      */
  469.     public Component getGlassPane() { 
  470.         return getRootPane().getGlassPane(); 
  471.     }
  472.  
  473.     /**
  474.      * Sets the glassPane property. 
  475.      * This method is called by the constructor.
  476.      * @param glassPane the glassPane object for this frame
  477.      *
  478.      * @see #getGlassPane
  479.      * @see RootPaneContainer#setGlassPane
  480.      *
  481.      * @beaninfo
  482.      *     hidden: true
  483.      *     description: A transparent pane used for menu rendering.
  484.      */
  485.     public void setGlassPane(Component glassPane) {
  486.         getRootPane().setGlassPane(glassPane);
  487.     }
  488.  
  489.  
  490.  
  491. /////////////////
  492. // Accessibility support
  493. ////////////////
  494.  
  495.     /** The accessible context property */
  496.     protected AccessibleContext accessibleContext = null;
  497.  
  498.     /**
  499.      * Get the AccessibleContext associated with this JFrame
  500.      *
  501.      * @return the AccessibleContext of this JFrame
  502.      */
  503.     public AccessibleContext getAccessibleContext() {
  504.         if (accessibleContext == null) {
  505.             accessibleContext = new AccessibleJFrame();
  506.         }
  507.         return accessibleContext;
  508.     }
  509.  
  510.     /**
  511.      * The class used to obtain the AccessibleRole for this object.
  512.      */
  513.     protected class AccessibleJFrame extends AccessibleContext
  514.         implements Serializable, AccessibleComponent {
  515.  
  516.         // AccessibleContext methods
  517.         /**
  518.          * Get the accessible name of this object.  
  519.          *
  520.          * @return the localized name of the object -- can be null if this 
  521.          * object does not have a name
  522.          */
  523.         public String getAccessibleName() {
  524.             if (accessibleName != null) {
  525.                 return accessibleName;
  526.             } else {
  527.                 if (getTitle() == null) {
  528.                     return super.getAccessibleName();
  529.                 } else {
  530.                     return getTitle();
  531.                 }
  532.             }
  533.         }
  534.  
  535.         /**
  536.          * Get the role of this object.
  537.          *
  538.          * @return an instance of AccessibleRole describing the role of the 
  539.          * object
  540.          * @see AccessibleRole
  541.          */
  542.         public AccessibleRole getAccessibleRole() {
  543.             return AccessibleRole.FRAME;
  544.         }
  545.  
  546.         /**
  547.          * Get the state of this object.
  548.          *
  549.          * @return an instance of AccessibleStateSet containing the current 
  550.          * state set of the object
  551.          * @see AccessibleState
  552.          */
  553.         public AccessibleStateSet getAccessibleStateSet() {
  554.             AccessibleStateSet states = SwingUtilities.getAccessibleStateSet(JFrame.this);
  555.             if (isResizable()) {
  556.                 states.add(AccessibleState.RESIZABLE);
  557.             }
  558.             if (getFocusOwner() != null) {
  559.                 states.add(AccessibleState.ACTIVE);
  560.             }   
  561.             // FIXME:  [[[WDW - should also return ICONIFIED and ICONIFIABLE
  562.             // if we can ever figure these out]]]
  563.             return states;
  564.         }
  565.  
  566.         /**
  567.          * Get the Accessible parent of this object.  If the parent of this
  568.          * object implements Accessible, this method should simply return
  569.          * getParent().
  570.          *
  571.          * @return the Accessible parent of this object -- can be null if this
  572.          * object does not have an Accessible parent
  573.          */
  574.         public Accessible getAccessibleParent() {
  575.             Container parent = getParent();
  576.             if (parent instanceof Accessible) {
  577.                 return (Accessible) parent;
  578.             } else {
  579.                 return null;
  580.             }
  581.         }
  582.  
  583.         /**
  584.          * Get the index of this object in its accessible parent. 
  585.          *
  586.          * @return the index of this object in its parent; -1 if this 
  587.          * object does not have an accessible parent.
  588.          * @see #getAccessibleParent
  589.          */
  590.         public int getAccessibleIndexInParent() {
  591.             return SwingUtilities.getAccessibleIndexInParent(JFrame.this);
  592.         }
  593.  
  594.         /**
  595.          * Returns the number of accessible children in the object.  If all
  596.          * of the children of this object implement Accessible, than this
  597.          * method should return the number of children of this object.
  598.          *
  599.          * @return the number of accessible children in the object.
  600.          */
  601.         public int getAccessibleChildrenCount() {
  602.             return SwingUtilities.getAccessibleChildrenCount(JFrame.this);
  603.         }
  604.  
  605.         /**
  606.          * Return the nth Accessible child of the object.  
  607.          *
  608.          * @param i zero-based index of child
  609.          * @return the nth Accessible child of the object
  610.          */
  611.         public Accessible getAccessibleChild(int i) {
  612.             return SwingUtilities.getAccessibleChild(JFrame.this,i);
  613.         }
  614.  
  615.         /**
  616.          * Return the locale of this object.
  617.          *
  618.          * @return the locale of this object
  619.          */
  620.         public Locale getLocale() {
  621.             return JFrame.this.getLocale();
  622.         }
  623.  
  624.         /**
  625.          * Get the AccessibleComponent associated with this object if one
  626.          * exists.  Otherwise return null.
  627.          */
  628.         public AccessibleComponent getAccessibleComponent() {
  629.             return this;
  630.         }
  631.  
  632.  
  633.         // AccessibleComponent methods
  634.         //
  635.         /**
  636.          * Get the background color of this object.
  637.          *
  638.          * @return the background color, if supported, of the object; 
  639.          * otherwise, null
  640.          */
  641.         public Color getBackground() {
  642.             return JFrame.this.getBackground();
  643.         }
  644.  
  645.         /**
  646.          * Set the background color of this object.
  647.          *
  648.          * @param c the new Color for the background
  649.          */
  650.         public void setBackground(Color c) {
  651.             JFrame.this.setBackground(c);
  652.         }
  653.  
  654.         /**
  655.          * Get the foreground color of this object.
  656.          *
  657.          * @return the foreground color, if supported, of the object; 
  658.          * otherwise, null
  659.          */
  660.         public Color getForeground() {
  661.             return JFrame.this.getForeground();
  662.         }
  663.  
  664.         /**
  665.          * Set the foreground color of this object.
  666.          *
  667.          * @param c the new Color for the foreground
  668.          */
  669.         public void setForeground(Color c) {
  670.             JFrame.this.setForeground(c);
  671.         }
  672.  
  673.         /**
  674.          * Get the Cursor of this object.
  675.          *
  676.          * @return the Cursor, if supported, of the object; otherwise, null
  677.          */
  678.         public Cursor getCursor() {
  679.             return JFrame.this.getCursor();
  680.         }
  681.  
  682.         /**
  683.          * Set the Cursor of this object.
  684.          *
  685.          * @param c the new Cursor for the object
  686.          */
  687.         public void setCursor(Cursor cursor) {
  688.             JFrame.this.setCursor(cursor);
  689.         }
  690.  
  691.         /**
  692.          * Get the Font of this object.
  693.          *
  694.          * @return the Font,if supported, for the object; otherwise, null
  695.          */
  696.         public Font getFont() {
  697.             return JFrame.this.getFont();
  698.         }
  699.  
  700.         /**
  701.          * Set the Font of this object.
  702.          *
  703.          * @param f the new Font for the object
  704.          */
  705.         public void setFont(Font f) {
  706.             JFrame.this.setFont(f);
  707.         }
  708.  
  709.         /**
  710.          * Get the FontMetrics of this object.
  711.          *
  712.          * @param f the Font
  713.          * @return the FontMetrics, if supported, the object; otherwise, null
  714.          * @see getFont
  715.          */
  716.         public FontMetrics getFontMetrics(Font f) {
  717.             return JFrame.this.getFontMetrics(f);
  718.         }
  719.  
  720.         /**
  721.          * Determine if the object is enabled.
  722.          *
  723.          * @return true if object is enabled; otherwise, false
  724.          */
  725.         public boolean isEnabled() {
  726.             return JFrame.this.isEnabled();
  727.         }
  728.  
  729.         /**
  730.          * Set the enabled state of the object.
  731.          *
  732.          * @param b if true, enables this object; otherwise, disables it 
  733.          */
  734.         public void setEnabled(boolean b) {
  735.             JFrame.this.setEnabled(b);
  736.         }
  737.         
  738.         /**
  739.          * Determine if the object is visible.  Note: this means that the
  740.          * object intends to be visible; however, it may not in fact be
  741.          * showing on the screen because one of the objects that this object
  742.          * is contained by is not visible.  To determine if an object is
  743.          * showing on the screen, use isShowing().
  744.          *
  745.          * @return true if object is visible; otherwise, false
  746.          */
  747.         public boolean isVisible() {
  748.             return JFrame.this.isVisible();
  749.         }
  750.  
  751.         /**
  752.          * Set the visible state of the object.
  753.          *
  754.          * @param b if true, shows this object; otherwise, hides it 
  755.          */
  756.         public void setVisible(boolean b) {
  757.             JFrame.this.setVisible(b);
  758.         }
  759.  
  760.         /**
  761.          * Determine if the object is showing.  This is determined by checking
  762.          * the visibility of the object and ancestors of the object.  Note: 
  763.          * this will return true even if the object is obscured by another 
  764.          * (for example, it happens to be underneath a menu that was pulled 
  765.          * down).
  766.          *
  767.          * @return true if object is showing; otherwise, false
  768.          */
  769.         public boolean isShowing() {
  770.             return JFrame.this.isShowing();
  771.         }
  772.  
  773.         /** 
  774.          * Checks whether the specified point is within this object's bounds,
  775.          * where the point's x and y coordinates are defined to be relative to 
  776.          * the coordinate system of the object. 
  777.          *
  778.          * @param p the Point relative to the coordinate system of the object
  779.          * @return true if object contains Point; otherwise false
  780.          */
  781.         public boolean contains(Point p) {
  782.             return JFrame.this.contains(p);
  783.         }
  784.     
  785.         /** 
  786.          * Returns the location of the object on the screen.
  787.          *
  788.          * @return location of object on screen -- can be null if this object
  789.          * is not on the screen
  790.          */
  791.         public Point getLocationOnScreen() {
  792.             return JFrame.this.getLocationOnScreen();
  793.         }
  794.  
  795.         /** 
  796.          * Gets the location of the object relative to the parent in the form 
  797.          * of a point specifying the object's top-left corner in the screen's 
  798.          * coordinate space.
  799.          *
  800.          * @return An instance of Point representing the top-left corner of 
  801.          * the objects's bounds in the coordinate space of the screen; null if
  802.          * this object or its parent are not on the screen
  803.          */
  804.         public Point getLocation() {
  805.             return JFrame.this.getLocation();
  806.         }
  807.  
  808.         /** 
  809.          * Sets the location of the object relative to the parent.
  810.          */
  811.         public void setLocation(Point p) {
  812.             JFrame.this.setLocation(p);
  813.         }
  814.  
  815.         /** 
  816.          * Gets the bounds of this object in the form of a Rectangle object. 
  817.          * The bounds specify this object's width, height, and location
  818.          * relative to its parent. 
  819.          *
  820.          * @return A rectangle indicating this component's bounds; null if 
  821.          * this object is not on the screen.
  822.          */
  823.         public Rectangle getBounds() {
  824.             return JFrame.this.getBounds();
  825.         }
  826.  
  827.         /** 
  828.          * Sets the bounds of this object in the form of a Rectangle object. 
  829.          * The bounds specify this object's width, height, and location
  830.          * relative to its parent.
  831.          *      
  832.          * @param A rectangle indicating this component's bounds
  833.          */
  834.         public void setBounds(Rectangle r) {
  835.             JFrame.this.setBounds(r);
  836.         }
  837.  
  838.         /** 
  839.          * Returns the size of this object in the form of a Dimension object. 
  840.          * The height field of the Dimension object contains this objects's
  841.          * height, and the width field of the Dimension object contains this 
  842.          * object's width. 
  843.          *
  844.          * @return A Dimension object that indicates the size of this 
  845.          * component; null if this object is not on the screen
  846.          */
  847.         public Dimension getSize() {
  848.             return JFrame.this.getSize();
  849.         }
  850.  
  851.         /** 
  852.          * Resizes this object so that it has width width and height. 
  853.          *      
  854.          * @param d - The dimension specifying the new size of the object. 
  855.          */
  856.         public void setSize(Dimension d) {
  857.             JFrame.this.setSize(d);
  858.         }
  859.  
  860.         /**
  861.          * Returns the Accessible child, if one exists, contained at the local
  862.          * coordinate Point.
  863.          *
  864.          * @param p The point defining the top-left corner of the Accessible, 
  865.          * given in the coordinate space of the object's parent. 
  866.          * @return the Accessible, if it exists, at the specified location; 
  867.          * else null
  868.          */
  869.         public Accessible getAccessibleAt(Point p) {
  870.             Accessible a;
  871.             AccessibleContext ac;
  872.             AccessibleComponent acmp;
  873.             Point location;
  874.             int nchildren = getAccessibleChildrenCount();
  875.             for (int i=0; i < nchildren; i++) {
  876.                 a = getAccessibleChild(i);
  877.                 if ((a != null)) {
  878.                     ac = a.getAccessibleContext();
  879.                     if (ac != null) {
  880.                         acmp = ac.getAccessibleComponent();
  881.                         if ((acmp != null) && (acmp.isShowing())) {
  882.                             location = acmp.getLocation();
  883.                             Point np = new Point(p.x-location.x, p.y-location.y)
  884. ;
  885.                             if (acmp.contains(np)){
  886.                                 return a;
  887.                             }
  888.                         }
  889.                     }
  890.                 }
  891.             }
  892.             return (Accessible) JFrame.this;
  893. //          return SwingUtilities.getAccessibleAt(JFrame.this,p);
  894.         }
  895.  
  896.         /**
  897.          * Returns whether this object can accept focus or not.
  898.          *
  899.          * @return true if object can accept focus; otherwise false
  900.          */
  901.         public boolean isFocusTraversable() {
  902.             return JFrame.this.isFocusTraversable();
  903.         }
  904.  
  905.         /**
  906.          * Requests focus for this object.
  907.          */
  908.         public void requestFocus() {
  909.             JFrame.this.requestFocus();
  910.         }
  911.  
  912.         /**
  913.          * Adds the specified focus listener to receive focus events from this 
  914.          * component. 
  915.          *
  916.          * @param l the focus listener
  917.          */
  918.         public void addFocusListener(FocusListener l) {
  919.             JFrame.this.addFocusListener(l);
  920.         }
  921.  
  922.         /**
  923.          * Removes the specified focus listener so it no longer receives focus 
  924.          * events from this component.
  925.          *
  926.          * @param l the focus listener
  927.          */
  928.         public void removeFocusListener(FocusListener l) {
  929.             JFrame.this.removeFocusListener(l);
  930.         }
  931.     } // inner class AccessibleJFrame
  932. }
  933.